<?php include('../config/config.php'); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-gb" lang="en-gb" dir="ltr">
<head>
	<meta http-equiv="content-Type" content="text/html; charset=utf-8"/>
	<meta http-equiv="Content-Language" content="fr"/>
	<title>Nouvelles Annales de Mathématiques - Les auteurs</title>
 	<meta name="language" content="fr-FR" />
	<meta name="robots" content="nofollow" />
	<meta name="keywords" content="<?php echo $longTitle;?>" />
	<meta name="author" content="Archives Henri Poincaré"/>
	<meta name="publisher" content="Laboratoire d'Histoire des Sciences et de Philosophie" />
	<meta name="copyright" content="Université Nancy 2, CNRS" />
	<style type="text/css" media="screen">@import url(./styles/style.css);</style>
	<link rel="shortcut icon" type="image/x-icon" href="images/favicon.ico"/>
	<script type="text/javascript">
		function select_all()
		{
		var text_val=eval("document.form1.bibtex");
		text_val.focus();
		text_val.select();
		}
	</script>
</head>
<body>
<h3 style="padding:1em;"><?php echo $longTitle;?></h3>
<div id="main" style="padding:0 1em;">
	<div id="searchForm" style="">
		<div class="mailto-close">
			<a href="#" onclick="window.close();return false;" title="Fermez la fenêtre"><span>Fermez la fenêtre</span></a>
		</div>
<?php
// Fichier de configuration fonction du serveur
include('../config/config.php');
$dsn='mysql:host='.$host.';port='.$port.';dbname='.$dbname;

include("../model/model.php");
$a = new model($dsn, $user, $pass);

$item = $a->selectItem($from, 'bibkey', $_GET['bibkey']);
?>
		<h3 class="titreForm"><?php echo $item[0]['bibkey'] ?></h3>
		<div style="margin-bottom:1em;">
			<span style="font-weight:bold; padding-right:1em;"><?php echo $item[0]['yr'] ?></span>
			<?php if(!empty($item[0]['art'])){?>
			<span style="font-weight:bold; padding-right:1em; color:#A7211D;"><?php echo $item[0]['art'] ?></span>
			<?php }
			if(!empty($item[0]['bk'])){?>
			<span style="font-weight:bold; padding-right:1em; color:#A7211D;"><?php echo $item[0]['bk'] ?></span>
			<?php } ?>
		</div>
		<form name="form1" method="post" action="">
<?php
// Bibref de la base
$bibref = preg_replace("/\t/", "\n", $item[0]['bibref']);
echo '		<textarea name="bibtex" rows="10" cols="40" class="inputbox" onClick="select_all();">'.$bibref.'</textarea>';


/* Tentative abandonnée car des éléments manquent pour faire du dynamique
// les types article, incollection, book, misc ou phdthesis, pagination impossibles à prévoir ?

foreach($item as $key=>$value){
	$bibkey = '@';
	if (!empty($value['art']) and empty($value['bk'])) $bibkey .= 'article';
	if (!empty($value['art']) and !empty($value['bk'])) $bibkey .= 'incollection';
	if (empty($value['art']) and !empty($value['bk'])) $bibkey .= 'book';
	$bibkey .= '{';
	// clé
	$bibkey .= $value['bibkey'].', ';
	// author
	if (!empty($value['ln'])){
		$bibkey .= 'author={';
		// nom
		$bibkey .= $value['ln'];
		// prénom
		if (!empty($value['ln'])) $bibkey .= ', '.$value['fn'];
		$bibkey .= '}, ';
	}
	// title article
	if (!empty($value['art'])) $bibkey .= 'title={'.$value['art'].'}, ';
	// title livre
	if (!empty($value['bk'])) $bibkey .= 'booktitle={'.$value['bk'].'}, ';
	// éditeur
	if (!empty($value['pb'])){
		$bibkey .= 'publisher={'.$value['pb'].'}, ';
		// ville éditeur
		if (!empty($value['city'])) $bibkey .= 'address={'.$value['city'].'}, ';
	}
	// journal
	if (!empty($value['jo'])){
		if($value['jo']=='CRAS') $value['jo']="Comptes rendus hebdomadaires de l'Acad\'emie des sciences";
		$bibkey .= 'journal={'.$value['jo'].'}, ';
	}
	// volume
	if (!empty($value['vo'])) $bibkey .= 'volume={'.$value['vo'].'}, ';
	// année
	if (!empty($value['yr'])) $bibkey .= 'year={'.$value['yr'].'}, ';
	// pages
	if (!empty($value['pg'])){
		$bibkey .= 'pages={';
		// page début
		$bibkey .= $value['pg'];
		// page fin
		if (!empty($value['pgend'])) $bibkey .= '--'.$value['pgend'];
		$bibkey .= '}, ';
	}
	// crossref
	if (!empty($value['crossref'])) $bibkey .= 'crossref={'.$value['crossref'].'}, ';
	// on enlève la dernière virgule
	echo substr($bibkey,0,-2).' }';
	echo '<hr/>';
}

print_r($item);
*/

?>
		<p>
			<button class="button" onclick="select_all();return false;"> Sélectionner </button>
			<button class="button" onclick="window.close();return false;"> Fermer </button>
		</p>
		</form>
	</div>
</div>
</body>
</html>
